package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class Test2 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();

        Method[] methods = cls.getMethods();
        for (Method method : methods) {
            int modifiers = method.getModifiers();
            int parameterCount = method.getParameterCount();
            if(parameterCount == 0& modifiers == Modifier.PUBLIC){
                method.invoke(obj);
                System.out.println(method.getName());
            }
        }
    }
}
